package com.recipedb.recipedb.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@Entity
@Table(name = "recipe_comment_like")
@IdClass(RecipeCommentLikeId.class)
public class RecipeCommentLike implements Serializable {

    @Id
    @Column(name = "user_id")
    private Long userId;

    @Id
    @Column(name = "comment_id")
    private Long commentId;

    /**
     * 数据库触发器自动生成 created_at
     * insertable=false：插入时不让 Hibernate 传 null
     * updatable=false：更新时不允许覆盖
     * @Generated(INSERT)：插入后回填数据库生成的值
     */
    @Column(name = "created_at", insertable = false, updatable = false)
    @Generated(GenerationTime.INSERT)
    private LocalDateTime createdAt;
}
